clear all

use "study3data.dta"

*post-only
reg educpost eductreat ideo PID if expcond==0
est store post

*quasi
reg educpost eductreat educ_quasi PID ideo if expcond==1
est store quasi

*prepost
reg educpost eductreat educ_pre PID ideo if expcond==2
est store pre

*differences in coefficients
suest post quasi pre
test [post_mean]eductreat=[quasi_mean]eductreat
test [post_mean]eductreat=[pre_mean]eductreat


*figure 1
gen x=_n
replace x=. if _n>3
gen est=.
gen se=.

reg educpost eductreat ideo PID if expcond==0
replace se=_se[eductreat] in 1
replace est=_b[eductreat] in 1
reg educpost eductreat educ_pre PID ideo if expcond==2
replace se=_se[eductreat] in 2
replace est=_b[eductreat] in 2
reg educpost eductreat educ_quasi PID ideo if expcond==1
replace se=_se[eductreat] in 3
replace est=_b[eductreat] in 3

gen lo=est-1.96*se
gen hi=est+1.96*se

twoway (scatter est x if x==1, mcol(black)) (scatter est x if x==2, mcol(gray)) (scatter est x if x==3, mcol(sky)) ///
	(rcap lo hi x if x==1, lcol(black)) (rcap lo hi x if x==2, lcol(gray)) (rcap lo hi x if x==3, lcol(sky) ///
	xsc(range(.5 3.5)) xlab(1 "Post-only" 2 "Pre-post" 3 "Quasi", labsize(medsmall)) yline(0) legend(off) ///
	xtitle("") ylab(-.4(.2).4, labsize(medsmall)) plotregion(margin(zero)) graphregion(margin(1 1 1 1)) ///
	subtitle("Study 3: Education") saving(study3.gph, replace))
